package com.cnsoft;


import org.cnsoft.config.MyConfigTaskService;
import org.cnsoft.framework.beans.MyBeanFactoryHelper;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

import com.zmsoft.boxy.sfg.cache.SFGGameInfoCacheService;

@SpringBootApplication
//自定义扫描路径
@ComponentScan({"org.cnsoft","com.cnsoft","org.zmsoft","com.zmsoft"})
public class RunningApplication extends SpringBootServletInitializer implements ApplicationRunner{

    //////////////////////////////////////启动运行/////////////////////////////////////////////
	public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(RunningApplication.class);
		springApplication.setBannerMode(Banner.Mode.OFF);
        springApplication.run(args);
        RunningApplication.run();
	}
	
    ////////////////////////////////////////启动后加载内容////////////////////////////////////////
	public static void run() {
		try {
			//系统初始化
			MyConfigTaskService system = MyBeanFactoryHelper.getBean(MyConfigTaskService.class);
			system.start();
			System.out.println("=============system start=============");
			
			SFGGameInfoCacheService myGameInfoCacheService = MyBeanFactoryHelper.getBean(SFGGameInfoCacheService.class);
			myGameInfoCacheService.loadGameDatas();
			System.out.println("=============game init=============");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void run(ApplicationArguments args) throws Exception {
//		ISystemConfig system = MyBeanFactoryHelper.getBean(ISystemConfig.class);
//		system.start();
	}
	
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(RunningApplication.class);
	}

}
